package com.gaocf.designpatterns.behavior.strategy;

/**
 * @author gaocf
 */
public class RebateCash extends Cash {
    private String rebateCondition;
    private String moneyOfRebate;

    public String getRebateCondition() {
        return rebateCondition;
    }

    public void setRebateCondition(String rebateCondition) {
        this.rebateCondition = rebateCondition;
    }

    public String getMoneyOfRebate() {
        return moneyOfRebate;
    }

    public void setMoneyOfRebate(String moneyOfRebate) {
        this.moneyOfRebate = moneyOfRebate;
    }

    public RebateCash(String rebateCondition, String moneyOfRebate) {
        this.rebateCondition = rebateCondition;
        this.moneyOfRebate = moneyOfRebate;
    }


    @Override
    public double calculateRealCash(double money) {
        return money > Double.valueOf(rebateCondition) ?
                money - Math.floor(money * Double.valueOf(moneyOfRebate) / Double.valueOf(rebateCondition)) :
                money;
    }
}
